﻿using IPlugin;
using Model.Elements;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SessionManager
{
    public class RubenHoneyPot : IPlugin.IPlugin
    {
        #region InfoPlugin

        public string[] Authors
        {
            get
            {
                return new string[] { "Manuel Fernandez" };
            }
        }

        public string Name
        {
            get
            {
                return "RubenHoneyPot";
            }
        }

        public string Description
        {
            get
            {
                return "Honeypot for 'funny' office co-workers";
            }
        }

        public IPlugin.PluginRing Ring
        {
            get
            {
                return IPlugin.PluginRing.Ring0;
            }
        }
        #endregion

        public Model.Elements.HttpPacket Start(Model.Elements.HttpPacket packet)
        {
            if (packet is Model.Elements.HttpResponsePacket)
            {
                HttpResponsePacket response = packet as HttpResponsePacket;
                
                if (response.data != null && (ASCIIEncoding.ASCII.GetString(response.data).ToLower().Contains("hasselhoff")||ASCIIEncoding.ASCII.GetString(response.data).ToLower().Contains("buchanan")))
                {
                    System.Diagnostics.Process p = new System.Diagnostics.Process();
                    p.StartInfo = new System.Diagnostics.ProcessStartInfo("rundll32.exe", "user32.dll, LockWorkStation");
                    p.Start();
                }
                return response;
            }
            else
            if (packet is Model.Elements.HttpRequestPacket)
            {
                HttpRequestPacket request = packet as HttpRequestPacket;
                if (request.uri.ToLower().Contains("hasselhoff"))
                {
                    System.Diagnostics.Process p = new System.Diagnostics.Process();
                    p.StartInfo = new System.Diagnostics.ProcessStartInfo("rundll32.exe", "user32.dll, LockWorkStation");
                    p.Start();
                }
            }


            return packet;
        }

    }

}
